﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ManualTools
{
    public partial class ResultForm : Form
    {
        
        public ResultForm(DataTable dtResult)
        {
            InitializeComponent();
            dgvResult.DataSource = dtResult;
        }

        private void ResultForm_Load(object sender, EventArgs e)
        {
            dgvResult.RowPostPaint += new DataGridViewRowPostPaintEventHandler(dgvResult_RowPostPaint);
        }

        private void dgvResult_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)//加行号
        {
            if (!dgvResult.RowHeadersVisible) return;
            Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
                                                e.RowBounds.Location.Y,
                                                dgvResult.RowHeadersWidth - 4,
                                                e.RowBounds.Height);

            TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
                                  dgvResult.RowHeadersDefaultCellStyle.Font,
                                  rectangle,
                                  dgvResult.RowHeadersDefaultCellStyle.ForeColor,
                                  TextFormatFlags.VerticalCenter | TextFormatFlags.Right);

        }
    }
}
